package com.structure.adapter;

/**
 * @author xiaobing
 * @version 1.0
 * @date 2021/9/6 5:27 下午
 */
public class MediaAdapter implements MediaPlayer {
    AdvancedMediaPlayer advancedMediaPlayer;

    public MediaAdapter(String type) {
        if ("VLC".equals(type)) {
            advancedMediaPlayer = new VlcPlayer();
        } else if ("Mp4".equals(type)) {
            advancedMediaPlayer = new Mp4Player();
        } else {
            throw new RuntimeException("类型错误！");
        }
    }

    @Override
    public void play(String type, String musicName) {
        if ("VLC".equals(type)) {
            advancedMediaPlayer.playVLC(musicName);
        } else if ("Mp4".equals(type)) {
            advancedMediaPlayer.playMp4(musicName);
        } else {
            throw new RuntimeException("类型错误！");
        }
    }
}
